<script>
	import Header from "@/components/Header.vue"
	export default {
		components: {
			Header
		},
		data() {
			return {
				finish: false, //是否结束
				id: 0,
				payType: 0,
				title: "详细信息",
				item: {},
				ziyuan: {},
				ziyuan_find: {},
				tanShow: false,
				tanText: '',
				myInfo: {},
				phone_word:'电话',
				lx_word:"",
				is_copy:1,
				pay_arr:[]
			}
		},
		onShareAppMessage() {
			return {
				title: '发布消息找到那个他/她',
				path: '/pages/index/index?id='+this.myInfo.me_invite_code,
				imageUrl: "https://seekerxcxoss.yiyankeji.vip/Label/Share_img.png"
			}
		},
		onLoad(options) {
			console.log(options)
			this.id = options.id
			if (options.forMe) {
				this.title = "提供线索详情"
				this.xiansuo()
			} else if (options.forOther) {
				this.title = "资源库匹配详情"
				this.ziyuan = JSON.parse(options.item)
				console.log(this.ziyuan)
				this.get_ziyuan()
			} else {
				this.index()
			}
			if (options.finish) this.finish = options.finish
			this.get_text()
			this.getMyInfo();
		},
		methods: {
			tel(phone){
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/Seek/getSignPhone',
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					data:{sign_id:that.id},
					success: (r) => {
						uni.makePhoneCall({
							phoneNumber: r.data.data.bo_phone
						})
					},
				})
				
			},
			getMyInfo() {
			
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/My/getMyInfo',
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						that.myInfo = r.data.data
						console.log("myInfo", that.myInfo)
					},
				})
			},
			get_text() {
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/My/getGzinfo',
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						that.tanText = r.data.data.zfcsfqgzwz
						console.log(r)
					},
				})


			},

			get_ziyuan() {
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/Seek/getSeekInfo',
					data: {
						seek_id: that.ziyuan.id
					},
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						console.log(r.data.data);
						that.ziyuan_find = r.data.data
					},
				})
			},
			deleteItem() {
				var that = this
				uni.showModal({
					title: "确认删除?",
					content: "删除后不可恢复",
					success: e => {
						if (e.confirm) {
							uni.request({
								url: getApp().globalData.host + '/api/Order/delMyPublish',
								data: {
									seek_id: that.id
								},
								header: {
									memberid: uni.getStorageSync('member_id'),
									membertoken: uni.getStorageSync('member_token'),
								},
								success: (r) => {
									if (r.data.code == 200) {
										uni.showToast({
											title: "操作成功",
											icon: "none"
										})
										setTimeout(function() {
											uni.navigateBack()
										}, 1500);
									} else {
										uni.showToast({
											title: r.data.msg,
											icon: "none"
										})
									}
								},
							})
						}
					}
				})
			},
			index() {
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/Seek/getSeekInfo',
					data: {
						seek_id: that.id
					},
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						that.item = r.data.data
						console.log(that.item)
					},
				})
			},
			goTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			xiangxiang() {
				var that = this
				that.tanShow = false
			},
			xiansuo() {
				var that = this
				uni.request({
					url: getApp().globalData.host + '/api/Seek/getSignInfo',
					data: {
						sign_id: that.id
					},
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						that.item = r.data.data
						
						console.log(that.item)
						if (r.data.code == 500) {
							uni.showModal({
								title: r.data.msg,
								showCancel: false,
								confirmText: "返回",
								success: e => {
									if (e.confirm) {
										uni.navigateBack()
									}
								}
							})
						}
						that.pay_arr = that.item.pay_arr
						that.is_copy = that.item.is_copy
						that.phone_word = that.item.phone_word
						that.lx_word = that.item.lx_word
						console.log(that.pay_arr)
					},
				})
			},
			pay(item) {

			},
			copyText() {
			  // 对于uni-app，可能需要使用uni.setClipboardData
			  uni.setClipboardData({
				data: this.item.sign_phone,
				success: function () {
				  uni.showToast({
					title: '复制成功',
					icon: 'success'
				  });
				}
			  });
			},
			preview(urls, current) {
				console.log(urls, current);
				uni.previewImage({
					urls,
					current
				})
			},
			editItem() {
				uni.navigateTo({
					url: "/pages/my/order/myPublish/edit?id=" + this.id
				})
			},
			payorder2() {
				var that = this
				that.tanShow = true
			},
			payorder() {
				var that = this
				that.tanShow = false

				if (that.payType == 0) {
					var pay_sign_money = that.item.seek_money * 0.5
				} else {
					var pay_sign_money = that.item.seek_money
				}
				uni.request({
					url: getApp().globalData.host + '/api/Seek/ascionPaySign',
					data: {
						sign_id: that.id,
						pay_sign_money: pay_sign_money
					},
					header: {
						memberid: uni.getStorageSync('member_id'),
						membertoken: uni.getStorageSync('member_token'),
					},
					success: (r) => {
						console.log(r)
						if (r.data.code == 200) {
							if (r.data.data.pay_type == '2') {
								uni.showToast({
									title: r.data.msg
								})
								return false
							} else {
								var orderInfo = r.data.data.info
								var seek_order_number = r.data.data.seek_order_number
								wx.requestPayment({
									timeStamp: orderInfo.timeStamp,
									nonceStr: orderInfo.nonceStr,
									package: orderInfo.package,
									signType: orderInfo.signType,
									paySign: orderInfo.paySign,
									success(res) {
										uni.showToast({
											title: '支付成功',
											icon: 'none',
											duration: 2000,
											success() {

											}
										})
										
										setTimeout(function(){
											uni.navigateBack({ delta: 1 })
										},2000)
									},
									fail() {
										uni.showToast({
											title: '取消支付',
											icon: 'none',
											duration: 2000,
											success() {

											}
										})
									}
								})
							}
						} else {
							uni.showModal({
								content: r.data.msg
							})
						}
					},
				})
			}
		}
	}
</script>
<template>
	<view class="p-30 custom-bg">
		<Header :title="title" />
		<div class="p-25 bg-white rounded-30 flex mb-18" v-if="title != '资源库匹配详情'">
			<div class="avatar flex-shirnk-0 w-80 h-80">
				<image :src="item.me_img" mode="aspectFill" class="w-full h-full rounded-full"></image>
			</div>
			<div class="flex flex-col ml-20 items-start">
				<div class="fz32 text-gray-16 flex">
					{{item.me_nick_name}}
					<div class="bg-purple fz22 text-white px-20 py-5 ml-20 rounded-30">提供茶水费：{{item.seek_money}}</div>
				</div>
				<div class="fz24 text-gray-a4 mt-10">发布时间：{{item.add_time}}</div>
			</div>
		</div>


		<view v-if="tanShow==true"
			style="background-color: #000;opacity: 0.8;width: 100%;height: 100%;position: fixed;left: 0%;top: 0%;z-index: 12;">
		</view>
		<view v-if="tanShow==true"
			style="background-color: #fff; border-radius: 10px; width: 70%;height: auto; padding: 20px; position: fixed;left: 15%;top: 30%;z-index: 13;">
			<view style="text-align: center;margin-top: 20rpx;font-weight: bold;">告知</view>
			<view style="text-align: left; color: #999; margin-top: 30rpx;line-height: 24px;font-size: 14px;">
				{{tanText}}
			</view>

			<view style="display: flex;width: 100%;margin-top: 30rpx;">
				<view @click="xiangxiang()"
					style=" width: 45%; margin-left: 3%; margin-right: 2%; height: 70rpx; text-align: center; line-height: 70rpx; border-radius: 50rpx; border: 1px solid #AC5FF8; color: #AC5FF8;">
					再想想</view>
				<view @click="payorder()"
					style=" width: 45%; margin-left: 3%; margin-right: 2%; height: 70rpx; text-align: center; line-height: 70rpx; border-radius: 50rpx; background-color:#AC5FF8; color: #fff;">
					立即支付</view>
			</view>


		</view>


		<!-- ======================需求相关 start ====================== -->

		<div class="p-25 bg-white rounded-30  mb-18" style="line-height: 45rpx;">
			<div class="text-purple fz28 mb-18">
				-基本信息-
			</div>
			<div class="fz28 text-gray-16">
				<block v-if="title != '资源库匹配详情'">
					<div v-for="(it,ind) in item.jb_seek_info" class="mb-10">{{it}}</div>
				</block>
				<block v-else>
					<div class="fz28 text-gray-16" v-for="(item,index) in ziyuan_find.jb_seek_info">
						<div class="mb-20">{{item}}</div>
					</div>
				</block>
			</div>
		</div>

		<div class="p-25 bg-white rounded-30  mb-18" v-if="title != '资源库匹配详情'">
			<div class="text-orange fz28 mb-18">
				-需求-
			</div>
			<div class="fz28 text-gray-16">
				<div>{{item.seek_type_word}}</div>
				<div style="white-space: normal;width: 95%; overflow-wrap: break-word;">{{item.seek_content}}</div>
			</div>
		</div>

		<div class="p-25 bg-white rounded-30  mb-18"
			v-if="title != '资源库匹配详情'&&item.seek_img_arr&&item.seek_img_arr.length>0">
			<div class="text-yellow fz28 mb-18">
				-图片信息-
			</div>
			<div class="flex px-30">
				<div v-for="(it,ind) in item.seek_img_arr" @click="preview(item.seek_img_arr,it)"
					class="relative mx-20">
					<image :src="it" mode="aspectFill" class="w-165 h-165 rounded-22 " style="display: block;">
					</image>
					<div class="pre absolute w-40 h-40 center r-0 b-0" style="background-color: rgba(0, 0, 0, 0.5);border-radius: 10rpx 0 20rpx 0;">
						<image src="/static/search.png" mode="widthFix" class="w-25"></image>
					</div>
				</div>

			</div>
		</div>

		<!-- ====================== 需求相关 end ====================== -->


		<!-- ======================线索相关 start====================== -->
		<div class="p-25 bg-white rounded-30  mb-18" v-if="title == '提供线索详情'">
			<div class="text-red fz28 mb-18">
				-线索信息-
			</div>
			<div class="flex mt-25">
				<image :src="item.sign_me_img" mode="aspectFill" class="w-90 h-90 rounded-full"></image>
				<div class="fz28 text-gray-16 ml-16 ">
					<div>{{item.sign_me_nick_name}}</div>
					<div style="width: 100%;display: flex;">
						<div class="mt-10" style="display: flex;" @click="tel(item.sign_phone)">
							<span>{{phone_word}} {{item.sign_phone}}  </span>
							<image src="../../static/common/phone.jpg" mode="widthFix" class="w-40 h-40 rounded-22 " style="margin-left: 10rpx;"></image> 
						</div> 
						<div v-if="is_copy==1" @click="copyText" class="mt-10" style="margin-left: 15rpx;color: #999;font-weight: 500;font-size: 24rpx;">复制</div>
					</div>
				</div>
			</div>
			<div class="flex mt-25" style="font-size: 24rpx;color:brown;">
				{{lx_word}}
			</div>

			<div class="text-yellow fz28 mb-18 mt-30">
				-线索图片-
			</div>
			<div class="flex px-30">
				<image :src="it" mode="aspectFill" class="w-165 h-165 rounded-22 mx-20"
					v-for="(it,ind) in item.sign_img_arr" @click="preview(item.sign_img_arr,it)"></image>
				<!-- <image src="../../static/logo.png" mode="aspectFill" class="w-165 h-165 rounded-22"></image>
				<image src="../../static/logo.png" mode="aspectFill" class="w-165 h-165 rounded-22"></image> -->
			</div>


			<!-- 寻其他 用这个标题 -->
			<div class="text-blue fz28 mb-18 mt-30">
				-线索描述-
			</div>
			<div class="fz28 text-gray-16">
				{{item.sign_content}}
			</div>
		</div>


		<!-- ======================线索相关 end====================== -->


		<div v-show="pay_arr.length!=0" class="p-25 bg-white rounded-30  mb-18" v-if="title == '提供线索详情'&&item.seek_money>0">
			<div class="text-green fz28 mb-18">
				-线索支付-
			</div>
			<div class="flex" style="justify-content: space-around;">

				<div class="w-220 h-180   rounded-22 bg-gray-800  flex-col center " :class="{'custom-input':payType==0}"
					@click="payType=0">
					<div class="fz34 font-bold" @click="pay(item)">支付50%</div>
					<div class="fz30 mt-13" @click="pay(item)">{{item.seek_money*0.5}}元</div>
				</div>
				<div class="w-220 h-180   rounded-22 bg-gray-800  flex-col center" :class="{'custom-input':payType==1}"
					@click="payType=1">
					<div class="fz34 font-bold" @click="pay(item)">全额付款</div>
					<div class="fz30 mt-13" @click="pay(item)">{{item.seek_money}}元</div>
				</div>
			</div>
		</div>


		<div class="p-25 bg-white rounded-30  mb-18" style="line-height: 55rpx;">
			<!-- 除了其他 用这个标题 -->
			<block v-if="title != '资源库匹配详情'">
				<div class="text-blue fz28 mb-18">
					-更多信息-
					<div v-for="(it,ind) in item.gd_seek_info">{{it,ind}}</div>
				</div>
			</block>
			<block v-else>
				<div class="text-blue fz28 mb-18">
					-更多信息-
				</div>
				<div class="fz28 text-gray-16" v-for="(item,index) in ziyuan_find.gd_seek_info">
					<div class="mb-20">{{item}}</div>
				</div>
			</block>

		</div>




		<!-- 判断看自己要隐藏按钮 -->
		<div class="submit  text-white p-30 bg-white">
			<block v-if="pay_arr.length!=0">
				<label  class="radio flex text-gray-16 mb-30 ml-20 fz24" v-if="title == '提供线索详情'&&item.seek_money>0">
					<radio color="#AC5FF8" /><text>支付前请同意<text class="text-purple">《云账户灵活用工协议》</text> <text class="text-purple">《用户行为规范》</text></text>
				</label>
			</block>
			
			<div v-show="pay_arr.length!=0" v-if="title == '提供线索详情'&&item.seek_money>0" class="bg-purple center h-90 rounded-50"
				@click="payorder2(item)">
				立即支付
			</div>
			<div class="bg-purple center h-90 rounded-50" @click="goTo('/pages/detail/receive/receive?id='+id)"
				v-if="item.is_teafee_button==1">
				领取茶水费
			</div>

			<div class="bg-purple center h-90 rounded-50"
				style="background-color: #eeeeee; color: #000; margin-top: 10rpx;" v-if="item.is_fs_button==1">
				您已发送联系方式
			</div>

			<div class="bg-purple center h-90 rounded-50" v-if="finish==2" @click="deleteItem()">
				删除
			</div>

			<div class="bg-purple center h-90 rounded-50" v-if="finish==1" @click="editItem()">
				编辑发布
			</div>
		</div>

		<div style="height: 300rpx;"></div>

	</view>
</template>



<style>
	.submit {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-shadow: 0 -10rpx 10rpx rgba(0, 0, 0, 0.05);
	}

	page {
		background-color: #F8F8F8;
	}
</style>